package com.demo.livemanagement.livedelayqueue;

import java.util.Date;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

public class TestQueue {
	private static final Logger LOGGER = Logger.getLogger(TestQueue.class);
	
	public static void main(String[] args) {
		@SuppressWarnings("unchecked")
		LiveDelayQueue<LiveDelayInfo> qu = LiveDelayQueue.getInstance();
		Thread tt = new Thread(new Runnable() {
			@Override
			public void run() {
				LOGGER.info(" ====生产者 thread start success====");
				long count = 0;
				while (true) {
					try {
						Thread.sleep(30000);
					} catch (InterruptedException e1) {
						e1.printStackTrace();
					}
					count++;
					try {
						TimeUnit.MILLISECONDS.sleep(5000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					LiveDelayInfo element = new LiveDelayInfo(new Date(),"test"+count);
					qu.offer(element);
					LOGGER.info(element);
					LOGGER.info("LiveDelayQueue size: "+qu.size());
				}
			}
		});
		tt.setName("---生产者线程---");
		tt.start();
		Thread t = new Thread(new LiveDelayTimeoutThread());
		t.setName("---消费者线程---");
		t.start();
		
		Date d=new Date();
		System.out.println(d.getTime());

	}
}
